<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <link rel="stylesheet" type="text/css" href="./css/aui-slide.css" />
    <script type="text/javascript" src="./script/base.js"></script>
    <script type="text/javascript" src="./script/api.js"></script>
    <script type="text/javascript" src="./script/doT.min.js"></script>
    <script type="text/javascript" src="./script/jquery.min.js"></script>
    <script type="text/javascript" src="./script/jquery-3.2.0.js"></script>
</head>
<body>
    <header class="aui-bar aui-bar-nav">
        <a class="aui-pull-left" onclick="closeWin()">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title">当前持仓</div>
    </header>
    <div id="list">
<!--         <div class="aui-bar-nav-d"></div>

        <style>
            body{background:#fff;}
        </style>
        <ul class="user-dqcc">
            <li class="aui-row">
                <h3>金车赢JSDY20180408003</h3>
                <div class="aui-col-xs-7">
                    <p>预期年化收益：6.40% </p>
                    <p>投资金额：人民币20000.00元</p>
                </div>
                <div class="aui-col-xs-5">
                    <p>投资周期：3个月</p>
                    <p>到期日：2018年9月1日</p>
                </div>
            </li>
        </ul> -->
    </div>
</body>
<script type="text/template" id="template">
    {{~it:value:index}}
    <div class="aui-bar-nav-d"></div>

    <style>
        body{background:#fff;}
    </style>
    <ul class="user-dqcc">
        <li class="aui-row">
            <h3>{{=value.name}}-{{=value.deal_sn}}</h3>
            <div class="aui-col-xs-7">
                <p>预期年化收益：{{=value.rate}}% </p>
                <p>投资金额：人民币{{=value.money}}元</p>
            </div>
            <div class="aui-col-xs-5">
                <p>投资周期：{{=value.repay_time}}个月</p>
                <p>到期日：{{=value.create_date}}</p>
            </div>
        </li>
    </ul>
    {{~}}
</script>
<script type="text/javascript">

    apiready = function(){
        updateData(4);
    }


    // 更新数据,模板函数
    function updateData(state){
        status = state;
        // 进度提示框
        api.showProgress({
            title: '努力加载中...',
            text: '请稍等...',
            modal: false
        });

        var userid = $api.getStorage('userid');
        api.ajax({
            url: webAddress + '/member.php?ctl=app_user_center&act=user_deallist',
            method: 'post',
            data: {
                values: {
                    user_id: userid,
                    deal_status: state,
                },
            }
        },function(ret, err){
            if (ret) {
                // alert($api.jsonToStr(ret));
                // 关闭下拉刷新控件
                api.refreshHeaderLoadDone();
                api.hideProgress();
                if (ret.status == 0) {
                    alert(ret.info);
                    return false;
                }else{
                    var data = ret.deals;
                    if (data == '') {
                        // if (state == 4) {
                            var list = $api.byId('list');
                            list.innerHTML = '<div class="login-list-no">没有持仓中项目</div>';
                        // }else if(state == 1){
                        //     var list = $api.byId('list');
                        //     list.innerHTML = '<div class="login-list-no">没有投标中的项目</div>';
                        // }else{
                        //     var list = $api.byId('list');
                        //     list.innerHTML = '<div class="login-list-no">没有已完成的项目</div>';
                        // }
                    }else{

                    // 修改金钱格式 已经列表右上角的状态
                  //   for (var i = 0; i < data.length; i++) {
                  //       if (state == 4) {
                  //           data[i].state = '回款中';
                  //       }else if (state == 1) {
                  //           data[i].state = '投标中';
                  //       }else{
                  //         data[i].state = '已完成';
                  //     }
                  //     data[i].money = outputmoney(data[i].money);
                  // }
                  templateFun(data);
              }
          }
      } else {
        alert(err.msg);
        api.refreshHeaderLoadDone();
        api.hideProgress();
    }
});
    };

    // 模板赋值函数
    function templateFun(data){
        var template = $api.byId('template');
        var dotFn = doT.template(template.innerHTML);
        var html = dotFn(data);
        var user = $api.byId('list');
        $api.html(user, html);
    }

    function closeWin(){
        api.closeWin({
        });
    }
</script>
</html>